package com.atguigu.java;

import java.util.Arrays;

/**
 * @author azzn1400820029
 * @create 2021-12-12 17:32
 */

/*
 * java.util.Arrays:操作数组的工具类，里面定义了很多操作数组的方法
 *
 *
 */

public class ArrayTest {
    public static void main(String[] args) {
//        1.判断两个数组是否相等
        int[] arr1 = new int[]{1, 2, 3, 4};
        int[] arr2 = new int[]{1, 6, 3, 4};
        boolean isEquals = Arrays.equals(arr1, arr2);
        System.out.println(isEquals);

//        2.输出数组信息
        System.out.println(Arrays.toString(arr1));

//        3.填充指定数值到数组中
        Arrays.fill(arr1, 2);
        System.out.println(Arrays.toString(arr1));

//        4.对数组进行排序
        Arrays.sort(arr2);
        System.out.println(Arrays.toString(arr2));

//        5.搜索指定元素
        int index = Arrays.binarySearch(arr2, 6);
        if (index >= 0) {
            System.out.println(index);
        } else  {
            System.out.println("no find");
        }
    }
}
